/**
 * 
 */
package com.java.test.messagecenter.dto;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.time.ZoneOffset;

import org.springframework.jdbc.core.RowMapper;

import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * @author 終端
 *
 */
public class TerminalInfo implements RowMapper<TerminalInfo> {

	private int id;

	// 终端渠道id
	private String tchannelId;
	// 终端渠道名称
	private String tchannelName;

	// 终端名称
	private String terminalName;

	// 适用地区
	private String areaId;
	
	private String areaName;

	// 备注
	private String content;

	// 添加人
	private String addPeople;

	// 添加时间
	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private LocalDateTime addTime;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getTchannelId() {
		return tchannelId;
	}

	public void setTchannelId(String tchannelId) {
		this.tchannelId = tchannelId;
	}

	public String getTerminalName() {
		return terminalName;
	}

	public void setTerminalName(String terminalName) {
		this.terminalName = terminalName;
	}


	public String getAreaId() {
		return areaId;
	}

	public void setAreaId(String areaId) {
		this.areaId = areaId;
	}

	public String getAreaName() {
		return areaName;
	}

	public void setAreaName(String areaName) {
		this.areaName = areaName;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getAddPeople() {
		return addPeople;
	}

	public void setAddPeople(String addPeople) {
		this.addPeople = addPeople;
	}

	public LocalDateTime getAddTime() {
		return addTime;
	}

	public void setAddTime(LocalDateTime addTime) {
		this.addTime = addTime;
	}

	
	public String getTchannelName() {
		return tchannelName;
	}

	public void setTchannelName(String tchannelName) {
		this.tchannelName = tchannelName;
	}

	@Override
	public TerminalInfo mapRow(ResultSet rs, int rowNum) throws SQLException {

		TerminalInfo info = new TerminalInfo();
		
		info.setId(rs.getInt("id"));
		
		info.setAddPeople(rs.getString("add_people"));
		
		info.setAddTime(rs.getTimestamp("add_time") == null ? null
				: rs.getTimestamp("add_time").toInstant().atZone(ZoneOffset.ofHours(8)).toLocalDateTime());
		
		info.setAreaId(rs.getString("area"));
		
		
		info.setContent(rs.getString("content"));
		
		info.setTchannelId(rs.getString("tchannel_id"));
		
		info.setTerminalName(rs.getString("terminal_name"));
		
		info.setTchannelName(rs.getString("tchannel_name"));
		
		return info;
	}

}
